class Solution {
public:
    int maxSubArray(vector<int>& nums) {
       int current=nums[0];
       int max_size=nums[0];
       int n=nums.size();
       for(int i=1;i<n;i++){
        int a;
        a=nums[i];
        current=max(a,a+current);
        max_size=max(max_size,current);
       }
       return max_size;
    }
};
